package cn.sh.yhk.mapper;

import cn.sh.yhk.model.Customer;
import cn.sh.yhk.model.CustomerExample;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface CustomerMapper {
    @SelectProvider(type=CustomerSqlProvider.class, method="countByExample")
    long countByExample(CustomerExample example);

    @DeleteProvider(type=CustomerSqlProvider.class, method="deleteByExample")
    int deleteByExample(CustomerExample example);

    @Delete({
        "delete from customer",
        "where customer_id = #{customerId,jdbcType=SMALLINT}"
    })
    int deleteByPrimaryKey(Short customerId);

    @Insert({
        "insert into customer (customer_id, store_id, ",
        "first_name, last_name, ",
        "email, address_id, ",
        "active, create_date, ",
        "last_update)",
        "values (#{customerId,jdbcType=SMALLINT}, #{storeId,jdbcType=TINYINT}, ",
        "#{firstName,jdbcType=VARCHAR}, #{lastName,jdbcType=VARCHAR}, ",
        "#{email,jdbcType=VARCHAR}, #{addressId,jdbcType=SMALLINT}, ",
        "#{active,jdbcType=BIT}, #{createDate,jdbcType=TIMESTAMP}, ",
        "#{lastUpdate,jdbcType=TIMESTAMP})"
    })
    int insert(Customer record);

    @InsertProvider(type=CustomerSqlProvider.class, method="insertSelective")
    int insertSelective(Customer record);

    @SelectProvider(type=CustomerSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.SMALLINT, id=true),
        @Result(column="store_id", property="storeId", jdbcType=JdbcType.TINYINT),
        @Result(column="first_name", property="firstName", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_name", property="lastName", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="address_id", property="addressId", jdbcType=JdbcType.SMALLINT),
        @Result(column="active", property="active", jdbcType=JdbcType.BIT),
        @Result(column="create_date", property="createDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_update", property="lastUpdate", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Customer> selectByExample(CustomerExample example);

    @Select({
        "select",
        "customer_id, store_id, first_name, last_name, email, address_id, active, create_date, ",
        "last_update",
        "from customer",
        "where customer_id = #{customerId,jdbcType=SMALLINT}"
    })
    @Results({
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.SMALLINT, id=true),
        @Result(column="store_id", property="storeId", jdbcType=JdbcType.TINYINT),
        @Result(column="first_name", property="firstName", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_name", property="lastName", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="address_id", property="addressId", jdbcType=JdbcType.SMALLINT),
        @Result(column="active", property="active", jdbcType=JdbcType.BIT),
        @Result(column="create_date", property="createDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_update", property="lastUpdate", jdbcType=JdbcType.TIMESTAMP)
    })
    Customer selectByPrimaryKey(Short customerId);

    @UpdateProvider(type=CustomerSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Customer record, @Param("example") CustomerExample example);

    @UpdateProvider(type=CustomerSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Customer record, @Param("example") CustomerExample example);

    @UpdateProvider(type=CustomerSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Customer record);

    @Update({
        "update customer",
        "set store_id = #{storeId,jdbcType=TINYINT},",
          "first_name = #{firstName,jdbcType=VARCHAR},",
          "last_name = #{lastName,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "address_id = #{addressId,jdbcType=SMALLINT},",
          "active = #{active,jdbcType=BIT},",
          "create_date = #{createDate,jdbcType=TIMESTAMP},",
          "last_update = #{lastUpdate,jdbcType=TIMESTAMP}",
        "where customer_id = #{customerId,jdbcType=SMALLINT}"
    })
    int updateByPrimaryKey(Customer record);
}